package com.cskaoyan.servlet;


import com.cskaoyan.bean.MarketAddress;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AdminAddressService;
import com.cskaoyan.service.AdminAddressServiceImpl;
import com.cskaoyan.util.ResponseUtil;
import com.cskaoyan.util.StringUtil;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/admin/address/*")

//小组接口收货地址信息的实现

public class AdminAddressServlet extends WdBaseServlet {

    AdminAddressService adminAddressService= new AdminAddressServiceImpl();

    @SneakyThrows
    private void list(HttpServletRequest request, HttpServletResponse response){

        Integer userId = StringUtil.isEmpty(request.getParameter("userId")) ? null : Integer.parseInt(request.getParameter("userId"));
        String name = request.getParameter("name");
        Integer page = StringUtil.isEmpty(request.getParameter("page")) ? null :Integer.parseInt(request.getParameter("page"));
        Integer limit = StringUtil.isEmpty(request.getParameter("limit")) ? null :Integer.parseInt(request.getParameter("limit"));
        String sort = request.getParameter("sort");
        String order = request.getParameter("order");

        CommonData<MarketAddress> commonData =  adminAddressService.list(userId,name,page,limit,sort,order);

        ResponseUtil.responseJson(response, BaseRespVo.ok(commonData));




    }
}
